package com.sm.dao;

import com.sm.entity.Role;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface RoleDao {

    //添加角色
    @Insert("insert inro role (rolename,roledesc) values(#{roleName},#{roleDesc})")
    public void addRole(Role role);

    //根据用户id查询出所有角色
    @Select("select * from role where rid in (select rid from user_role where uid = #{uid})")
    @Results(id = "roleMap",value =
            @Result(id = true,property = "id",column = "rid"))
    public List<Role> findRoleByUid(int uid);

    //查询出当前所有权限信息
    @Select("select * from role")
    @ResultMap("roleMap")
    public List<Role> findAllRole();

    //查询职务工资
    @Select("select jobSalary from role where rid = #{rid}")
    public Integer findJobSalary();

}
